'''
Description: 本文件供外部程序调用
Author: 
LastEditors: M
'''
import os,json
from piker.compoments.config import PIKER_DIR,exp_config
def _errormsg(*k,emphasis=None):
    msg = ",".join(k)
    print(f"ERROR:{msg}",end="")
    if emphasis:
        print(f"\033[1;31m\n\t{emphasis}\033[0m")
    else:
        print("")
_params_p = os.path.join(PIKER_DIR,exp_config)
def _load_params():
    if not os.path.exists(_params_p):
        _errormsg("参数配置文件不存","请先整理生成参数配置文件:",emphasis=_params_p)
        exit(-1)
    try:
        params = json.load(open(_params_p,encoding="utf-8"))
        return params
    except Exception as e:
        _errormsg("参数配置文件加载错误,检查内容格式是否正确",emphasis=f"{_params_p}\n\t{str(e)}")

def get_current_params():
    return _load_params()

Params = get_current_params()